<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>盘登录</title>

    <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/util.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>

<div class="limiter">
    <div class="container-login100" style="background-image: url('images/bg-01.jpg');">
        <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-54">
                <span class="login100-form-title p-b-49">登录</span>

                <div class="wrap-input100 validate-input m-b-23" data-validate="请输入用户名">
                    <span class="label-input100">用户名</span>
                    <input class="input100" type="text" id="userName" name="userName" placeholder="请输入用户名" autocomplete="off">
                    <span class="focus-input100" data-symbol="&#xf206;"></span>
                </div>

                <div class="wrap-input100 validate-input" data-validate="请输入密码">
                    <span class="label-input100">密码</span>
                    <input class="input100" type="password" id="password" name="password" placeholder="请输入密码">
                    <span class="focus-input100" data-symbol="&#xf190;"></span>
                </div>

                <div class="container-login100-form-btn">
                    <div class="wrap-login100-form-btn">
                        <div class="login100-form-bgbtn"></div>
                        <button id="doLogin" class="login100-form-btn">登 录</button>
                    </div>
                </div>

                <div class="txt1 text-center p-t-54 p-b-20">
                    <span>欢迎登陆网盘</span>
                </div>

                <div class="flex-c-m">
                    <a href="#" class="login100-social-item bg1">
                        <i class="fa fa-wechat"></i>
                    </a>

                    <a href="#" class="login100-social-item bg2">
                        <i class="fa fa-qq"></i>
                    </a>

                    <a href="#" class="login100-social-item bg3">
                        <i class="fa fa-weibo"></i>
                    </a>
                </div>

        </div>
    </div>
</div>

<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/main.js"></script>
<script>
    $(function() {
        //简单登录操作
        $("#doLogin").click(function (e) {
                $.ajax({
                    type: "POST",
                    url: "/login",
                    data: {
                        "userName": $("#userName").val(),
                        "password": $("#password").val()
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.result == "1") {
                            window.location.href = "main";
                        } else if (data.result == "2") {
                            alert("密码错误！");
                        } else {
                            alert("用户不存在或账号密码不能为空！");
                        }
                    }
                });
        });
    });
    //回车登录
    function enterlogin(){
        if (event.keyCode == 13){
            event.returnValue=false;
            event.cancel = true;
            if($("#userName").val() != "" && $("#password").val() != "") {
                $("#doLogin").click();
            }
        }
    }
</script>
</body>

</html>